#ifndef __SERVER_H__
#define __SERVER_H__

#include "head.h"
#include "md5.h"

#define READ_DATA_SIZE  1024
#define MD5_SIZE        16
#define MD5_STR_LEN     (MD5_SIZE * 2)

int epollDelFd(int epfd, int fd);
int serverLogin(int sockFd);
int CMDtype(const char *buf, char *cmd, char *arg);
int serverCd(int sockFd, int *curDirID, int ownerID, char *dirName);
int myls3(int sockFd, int ownerID, int curDirID);
int serverPwd(int sockFd, int curDirID, int ownerID);
int serverGets(int sockFd, int curDirID, int ownerID);
int getPath(char *filePath, int fileID, int ownerID);
int getParent(MYSQL *conn, char *filePath, int fileID, int ownerID);
int Compute_file_md5(const char *file_path, char *value);
int serverPuts(int sockFd, char *filename, int curDirID, int ownerID);
int serverMkdir(int sockFd, const char *dirname, int curDirID, int ownerID);
int sendFile(int sockFd, const char *filename);
int serverRm(int sockFd, char *filename, int curDirID, int ownerID);
int parsePath(char *filePath, int curDirID, int ownerID, char *md5str, char *type);

//对数据库操作的函数
int query_cd(char *dirname, int curDirID, int ownerID);
int updatePwd(int userID, char *curPath);
int query_dir(int ownerID, int curDirID, pFileInfo files[]);
int query_file(char *filename, int ownerID, char *filepath, long *file_size, char *filetype);
int query_parentID(int dirID, int ownerID);
int query_childID(MYSQL *conn, int curDirID, char *filename, int ownerID, char *md5str, char *type);
int query_md5str(const char *filename, int curDirID, int ownerID, char *md5str);
int query_newdir(const char *diarname, int curDirID, int ownerID);
int query_newfile(const char *diarname, int curDirID, int ownerID);
int query_count(const char *md5str);
int query_countChild(int parentID);
int insertNewfile(int parentID, const char *filename, int ownerID, char *md5str, int filesize, char type);
int insertLog(int userID, char *cmd);
int deleteFile(int fileID);

#endif
